package cn.wingware.util;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class SpringFilter implements Filter{

	Log log =  LogFactory.getLog(SpringFilter.class);
	
	public void destroy() {
		
	}

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain filter) throws IOException, ServletException {
		filter.doFilter(request, response);	
	}

	public void init(FilterConfig filterConfig) throws ServletException {
		/*
		 * spring初始化
		 */
		SpringUtils.newInstants().init(WebApplicationContextUtils.getWebApplicationContext(filterConfig.getServletContext()));
		log.debug("init SpingUtils");
	}

}

